package demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

 /**
 * @author RDSunday
 * @create 2020-08-17 9:17
 **/
@RestController
public class HelloController {

    @Autowired
     JdbcTemplate jdbcTemplate;
    @RequestMapping("/testhello")

    public  String getHello() {
        String sql = "SELECT mobile FROM user WHERE id = ?";
        // 通过jdbcTemplate查询数据库
        String mobile = (String)jdbcTemplate.queryForObject(
                sql, new Object[] { 1 }, String.class);
        System.out.println("@@@@@@@@@@@@@@@@@"+mobile);
        return "Hello " + mobile;
    }


}
